<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>
<body>
  <h1>axios</h1>
</body>
</html>
<script src="../node_modules/axios/dist/axios.js"></script>
<script>
  var options = {
    // url: 'http://test.huoqishi.net/question',
    url: 'http://127.0.0.1:8088/question',
    method: 'post',
    // headers: {
    //   // 阅读跨域CORS详情!
    //   'content-Type': 'application/x-www-form-urlencoded'
    // },
    data: {
      username: '火骑士空空',
      hasFriend: '1',
      howAge: 18,
      whenWork: 1998,
      // hobby: null,
      hobby: ['chifan', 'shuijiao'], // 这里必需写个空数组才行
      suggestion: '你好吗?'
    }
  }
  axios(options).then(res => {
    // window.alert(r)
    console.log(res.data)
    if (res.data.code === 2000) {
      window.alert(res.data.errMsg)
    }
  })
</script>